package com.yygo.jobs;

import com.yygo.model.LoanRequest;
import com.yygo.model.Rule;
import com.yygo.service.LoanRequestManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by tiansha on 2015/7/4.
 */
@Component("R001")
public class R001 implements RuleProcessor {

    @Autowired
    private LoanRequestManager loanRequestManager;

    @Override
    public Rule process(LoanRequest loanRequest) {
        String city = loanRequest.getDealer().getCity();
        boolean flag = true;
        if (!city.equals(loanRequest.getRequestPerson().getMobileCity()) ||
                (loanRequest.getCoPerson() != null && !city.equals(loanRequest.getCoPerson().getMobileCity())) ||
                (loanRequest.getDbPerson() != null && !city.equals(loanRequest.getDbPerson().getMobileCity()))) {
            flag = false;
        }
        if (flag == false) {
            Rule rule = new Rule("R001", "手机号码归宿地与经销商所在城市不一致");
            return rule;
        }
        return null;
    }

}